using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Updater
{
    static class Program
    {
        /// <summary>
        ///  The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main(string[] args)
        {
            Application.SetHighDpiMode(HighDpiMode.SystemAware);
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            string sarg = "";
            for (int i = 0; i < args.Length; i++)
            {
                switch (args[i])
                {
                    case "-delay":
                        i++;
                        Thread.Sleep(Convert.ToInt32(args[i]));
                        break;
                    case "-start":
                        System.Diagnostics.ProcessStartInfo processStartInfo = new System.Diagnostics.ProcessStartInfo(Path.Combine(AppDomain.CurrentDomain.BaseDirectory ?? "", "ICU.exe"));
                        processStartInfo.Arguments = sarg.Replace("\\\"", "\"");
                        System.Diagnostics.Process.Start(processStartInfo);
                        return;
                    case "-args":
                        i++;
                        sarg = args[i];
                        break;
                    case "-copy":
                        i += 2;
                        File.Copy(args[i - 1], args[i]);
                        File.Delete(args[i - 1]);
                        break;
                    default:
                        break;
                }
            }
            Application.Exit();
        }
    }
}
